package com.ding.easyme.app.util;

import java.util.HashMap;

public class Sequences {
	private int value = 0;
	
	public Sequences(){
		super();
	}
	
	public synchronized int nextVal(){
		if (value == Integer.MAX_VALUE) value = 0;
		return ++value;
	}	
	
	private static HashMap<Object, Sequences> seqList = new HashMap<Object, Sequences>();
	
	public static synchronized Sequences getInstance(Object seqName) {
		Sequences seq = null;
		seq = seqList.get(seqName);
		if (seq == null){
			seq = new Sequences();
			seqList.put(seqName, seq);
		}
		return seq;		
	}	

}
